package com.huifer.wgx.geoverify;

import com.huifer.wgx.model.DetectionLineEntity;
import com.huifer.wgx.model.DetectionPointEntity;
import com.huifer.wgx.model.InteriorLineEntity;
import com.huifer.wgx.model.FieldPointEntity;
import com.huifer.wgx.model.InteriorLineEntity;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>Title : LineVerify </p>
 * <p>Description : 线段异常查询</p>
 *
 * @author huifer
 * @date 2019-03-21
 */
public class LineVerify {

    /**
     * id单数双数判断
     *
     * @param allPoint 所有点
     * @return {"单数":[],"双数":[]}
     */
    public static List<DetectionLineEntity> onlyPoint(
            List<InteriorLineEntity> allPoint, Long verifyId, Long personnelId) {

        List<DetectionLineEntity> result = new ArrayList<>();

        List<InteriorLineEntity> singular = new ArrayList<>();
        List<InteriorLineEntity> even = new ArrayList<>();

        for (InteriorLineEntity fieldPointEntity : allPoint) {
            if (fieldPointEntity.getInteriorLineId() % 2 == 0) {
                even.add(fieldPointEntity);
            } else {
                singular.add(fieldPointEntity);
            }
        }

        for (int i = 0; i < singular.size(); i++) {
            DetectionLineEntity linedi = new DetectionLineEntity();
            linedi.setInteriorLineId(singular.get(i).getInteriorLineId());
            linedi.setVerifyId(verifyId);
            linedi.setPersonnelId(personnelId);
            linedi.setDetecionIsok("单数通过");
            result.add(linedi);
        }

        for (int i = 0; i < even.size(); i++) {
            DetectionLineEntity linedi = new DetectionLineEntity();
            linedi.setInteriorLineId(even.get(i).getInteriorLineId());
            linedi.setVerifyId(verifyId);
            linedi.setPersonnelId(personnelId);
            linedi.setDetecionIsok("双数通过");
            result.add(linedi);
        }
        return result;
    }
}
